package dk.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import dk.beans.subject;
import dk.beans.to.subjectlistToexamlist;

public interface subjectmapper extends BaseMapper<subject>{
	
@Select("SELECT\r\n" + 
		"	count( s.id ) as questionnum,\r\n" + 
		"	e.subjectid \r\n" + 
		"FROM\r\n" + 
		"	SUBJECT AS s\r\n" + 
		"	RIGHT JOIN examlist AS e ON s.id = e.subjectid \r\n" + 
		"GROUP BY\r\n" + 
		"	subjectid ")	
List<subjectlistToexamlist> selectquestionnum();
@Select("SELECT\r\n" + 
		"	s.id,\r\n" + 
		"	s.NAME AS NAME,\r\n" + 
		"	s.createtime AS createtime,\r\n" + 
		"	s.updatetime AS updatetime,\r\n" + 
		"	s.img_url AS img_url,\r\n" + 
		"IF\r\n" + 
		"	( subjectid = NULL, 0, count( subjectid ) ) AS questionnum \r\n" + 
		"FROM\r\n" + 
		"	`subject` AS s\r\n" + 
		"	LEFT JOIN examlist AS e ON s.id = e.subjectid \r\n" + 
		"GROUP BY\r\n" + 
		"	s.id")
public List<subject> IselectSubjectList();
}
